package com.zj.z11select.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.zj.z11select.utils.DateUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * 自动填充字段
 * @author ZHOUJIE <a>z-houjie@qq.com</a>
 * @date 2021-07-08 12:00
 */
@Component
public class AutoMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        strictInsertFill(metaObject,"userSex",Integer.class,3);
        strictInsertFill(metaObject,"userPic",String.class,"/default.png");
        strictInsertFill(metaObject,"createTime", Date.class, DateUtils.getNowDate());
        strictInsertFill(metaObject,"updateTime", Date.class, DateUtils.getNowDate());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        strictUpdateFill(metaObject,"updateTime", Date.class, DateUtils.getNowDate());

    }
}
